module dgl.Quaternion;

import dgl.Vector2;
import dgl.Vector3;

struct Quaternion
{
	private float[4] m_vector;
	
	public float x()
	{
		return m_vector[0];
	}
	
	public float y()
	{
		return m_vector[1];
	}
	
	public float z()
	{
		return m_vector[2];
	}
	
	public float w()
	{
		return m_vector[3];
	}
	
	public void x( float x )
	{
		m_vector[0] = x;
	}
	
	public void y( float y )
	{
		m_vector[1] = y;
	}
	
	public void z( float z )
	{
		m_vector[2] = z;
	}
	
	public void w( float w )
	{
		m_vector[3] = w;
	}
	
	public float * ptr()
	{
		return m_vector.ptr;
	}
	
	public static Quaternion opCall( float x, float y, float z, float w )
	{
		Quaternion ret;
		ret.x = x;
		ret.y = y;
		ret.z = z;
		ret.w = w;
		return ret;
	}
	
	public static Quaternion opCall( float value )
	{
		Quaternion ret;
		ret.x = value;
		ret.y = value;
		ret.z = value;
		ret.w = value;
		return ret;
	}
	
	public static Quaternion opCall( Vector2 value, float z, float w )
	{
		Quaternion ret;
		ret.x = value.x;
		ret.y = value.y;
		ret.z = z;
		ret.w = w;
		return ret;
	}
	
	public static Quaternion opCall( Vector3 value, float w )
	{
		Quaternion ret;
		ret.x = value.x;
		ret.y = value.y;
		ret.z = value.z;
		ret.w = w;
		return ret;
	}
	
	public static Quaternion identity()
	{
		return Quaternion( 0, 0, 0, 1 );
	}
}